package main

import (
	"fmt"
	"sync"
)

type atomicInt struct {
	value int
	lock  sync.Mutex
}

func (i *atomicInt) increase() {
	i.lock.Lock()
	defer i.lock.Unlock()
	i.value++
}

func (i *atomicInt) get() int {
	i.lock.Lock()
	defer i.lock.Unlock()
	return int(i.value)
}

func main() {
	var a atomicInt
	ok := make(chan bool)
	a.increase()
	go func() {
		a.increase()
		ok <- true
	}()
	<-ok
	fmt.Println(a.get())
}
